// Browser.cpp: implementation of the Browser class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Browser.h"
#include "BrowserPeer.h"

IMPLEMENT_DYNAMIC(Browser, AWTComponent)

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

Browser::Browser()
{

}

Browser::Browser(CString& url)
{
	m_url = url;
}

Browser::Browser(LPTSTR url)
{
	m_url = url;
}

Browser::~Browser()
{

}

CWnd* Browser::createComponent()
{
	CWnd* wParent = getParent()->getPeer();
	if (wParent == NULL)
		return wParent;
	BrowserPeer* pwnd = new BrowserPeer(this);
	CWnd* wndParent = getParent()->getPeer();
	if (wndParent == NULL)
		return NULL;
	pwnd->Create(NULL, _T(""), WS_CHILD | WS_VISIBLE, getBounds(), wndParent, 100);
	if (!m_url.IsEmpty())
		pwnd->SetURL(m_url);	
	return pwnd;
}

CSize Browser::getMinimumSize()
{
	return getPreferredSize();
}

CSize Browser::getPreferredSize()
{
	if (m_peer == NULL)
		return CSize(0,0);
	return CSize(10,10);
}

void Browser::setURL(CString& url)
{
	m_url = url;
	if (m_peer != NULL)
		((BrowserPeer*)m_peer)->SetURL(m_url);	
}